package com.generator.main;

import com.generator.util.GeneratorUtil;
import org.apache.velocity.exception.ResourceNotFoundException;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static String projectPath = System.getProperty("user.dir")+"\\RapidGenerator\\src\\com\\generator\\template";
    //自行配好要生成的数据库
    public static  String  dbName = "tool_plat_bf";
    public static String url = "jdbc:mysql://127.0.0.1:3306/";
    public static String account = "root";
    public static String password = "root";
    public static String author = "linhengming";
    public static String outputPath = "C://Users//Administrator//Desktop//ZCodes//"; //生成的代码输出路径
    //包路径及表名，根据业务模块调整
    public static String packageUrl = "com.modules.timer";
    public static String tableName = "timer_task";

    /**
     * 运行主方法即可
     * @param args
     */
    public static void main(String[] args) {
        try{
            //执行数据库生成
            System.out.println("代码生成中。。。");
            String result = GeneratorUtil.createCode();
            System.out.println("生成结果："+result);
            System.out.println("执行完毕。。。");
        }catch (ResourceNotFoundException e){
            System.out.println("项目路径不正确："+projectPath);
        }catch (Exception e){
            e.printStackTrace();
        }


    }

    //要生成代码的模板
    public static List<String> getTemplates(){
        List<String> templates = new ArrayList<String>();
        templates.add("Entity.java.vm");
        templates.add("Dao.java.vm");
        templates.add("Dao.xml.vm");
        templates.add("Service.java.vm");
        templates.add("ServiceImpl.java.vm");
        return templates;
    }
}
